﻿using SF.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SF.Ucenter.admin.goods.orders
{
    public partial class order_msg : Web.UI.ManagePage
    {
        private int id = 0;
        protected string dis = "none";
        protected Model.sf_goods_order model = new Model.sf_goods_order();

        protected void Page_Load(object sender, EventArgs e)
        {
            this.id = DTRequest.GetQueryInt("id");
            if (this.id == 0)
            {
                JscriptMsg("传输参数不正确！", "back");
                return;
            }
            if (!new BLL.sf_goods_order().Exists(this.id))
            {
                JscriptMsg("记录不存在或已被删除！", "back");
                return;
            }
            if (!Page.IsPostBack)
            {
                ChkAdminLevel("goods_orders_list", DTEnums.ActionEnum.View.ToString()); //检查权限
                ShowInfo(this.id);
            }
        }

        #region 赋值操作=================================
        private void ShowInfo(int _id)
        {
            BLL.sf_goods_order bll = new BLL.sf_goods_order();
            model = bll.GetModel(_id);
            BLL.sf_goods_orderdetal detalbll = new BLL.sf_goods_orderdetal();
            List<Model.sf_goods_orderdetal> detalList = detalbll.GetModelList("orderNum='" + model.orderNum+ "' and " + Utils.getWhereByInfo(model.busnieseNum, model.appNum, model.templatesNum));
            //对 打印运单 操作所需信息 赋值（针对aojieer）
            if (model.appNum.Equals("wxe68d84dbc2554452"))
            {
                dis = "block";
            }
            string adressText = model.id + "," + model.isExpress + "_" + model.addressText + "_";
            for (int i = 0; i < detalList.Count; i++)
            {
                adressText += getGoodsMsg(detalList[i].goodsNum) + "|" + detalList[i].numbers + ",";
            }
            addressText.Text = adressText;
            //绑定商品列表
            this.rptList.DataSource = detalList;
            this.rptList.DataBind();
            //获得客户信息
            if (model.userNum != "")
            {
                Model.sf_user_info user_info = new BLL.sf_user_info().GetModelByNum(model.userNum, Utils.getWhereByInfo(model.busnieseNum, model.appNum, model.templatesNum));
                if (user_info != null)
                {
                    dlUserInfo.Visible = true;
                    lbUserName.Text = user_info.nickName;
                    lbUserNum.Text = user_info.userNum;
                }
            }
        }
        #endregion
        public string getGoodsMsg(string goodsNum) 
        {
            Model.sf_goods_info goodsInfo = new BLL.sf_goods_info().GetModel("goodsNum='" + goodsNum + "' and " + Utils.getWhereByInfo(model.busnieseNum, model.appNum, model.templatesNum));
            string res = goodsInfo.names;
            return res;
        }


    }
}